import Tkinter as tk
from model2 import *
from view2 import *


class Controller(object):
    def __init__(self, model):
        self.model = model
        self.views = []

    def handle_insert(self, value):
        self.model.add(value)

    def handle_delete(self, index):
        self.model.delete(index)

    def get_data(self):
        return self.model.data()

    def update(self):
        for view in self.views:
            view.update()


if __name__ == '__main__':
    root = tk.Tk()

    model = Model()
    controller = Controller(model)
    view = View(root, controller)

    model.controllers.append(controller)
    controller.views.append(view)

    root.mainloop()
